package com.example.my_invitation_service.conf;


import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Bean
    @ConditionalOnProperty(name = "init.druid", havingValue = "true", matchIfMissing = false)
    public DataSource druidDataSource() {
        // 配置并返回Druid数据源
        return DruidDataSourceBuilder.create().build();
    }

}
